<?php
namespace app\api\controller\v1;
use think\facade\Request;
use think\Controller;

class Collect extends Base
{
 protected $beforeActionList = [
       'vali'
        //第一个''写前置方法的名字 ，后是需要用到前置方法的名字
    ];
    	private $obj;

    	protected function vali(){
        
    	$data = Request::param();
        $token = Request()->header('Token');

        if(isset($data['uid'])&&!empty($data['uid'])&&$data['uid'] != 'undefined' && !empty($token)){
            $uid = $data['uid'];
            $status = $this->verifyToken($uid,$token);
        
              if($token && $status){
                $this->obj = model("collect");
        }
    }else{
            return_json(40001,'token过期了',40001);
        	        }

    	}



	public function collect(){
		$data = Request::get();
		$this->obj->add($data); 
	}

	public function cancel(){
		//还得判断token
		$data = Request::get();
		$this->obj->cancel($data); 
	}

	public function select(){
		$uid = Request::get('uid');
		$this->obj->select($uid);
	}
   
}
?>